

package com.hazelcast.internal.metrics.impl;

import com.hazelcast.internal.metrics.MetricDescriptor;
import com.hazelcast.internal.metrics.collectors.MetricsCollector;

public class CompositeMetricsCollector implements MetricsCollector {

    private final MetricsCollector[] collectors;

    public CompositeMetricsCollector(MetricsCollector... collectors) {
        this.collectors = collectors;
    }

    @Override
    public void collectLong(MetricDescriptor descriptor, long value) {
        for (MetricsCollector collector : collectors) {
            collector.collectLong(descriptor, value);
        }
    }

    @Override
    public void collectDouble(MetricDescriptor descriptor, double value) {
        for (MetricsCollector collector : collectors) {
            collector.collectDouble(descriptor, value);
        }
    }

    @Override
    public void collectException(MetricDescriptor descriptor, Exception e) {
        for (MetricsCollector collector : collectors) {
            collector.collectException(descriptor, e);
        }
    }

    @Override
    public void collectNoValue(MetricDescriptor descriptor) {
        for (MetricsCollector collector : collectors) {
            collector.collectNoValue(descriptor);
        }
    }
}
